<!--
(c) Copyright Cory Plotts.
This source is subject to the Microsoft Public License (Ms-PL).
Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
All other rights reserved.
-->
<ResourceDictionary 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:my="clr-namespace:Snoop"
>
	<Style TargetType="{x:Type my:StandardValueEditor}">
		<Style.Resources>
			<DataTemplate x:Key="UnselectedValueTemplate">
				<TextBlock Style="{x:Null}" Text="{Binding DescriptiveValue}"/>
			</DataTemplate>

			<DataTemplate x:Key="SelectedValueTemplate">
				<my:EditTextBox Height="16" Text="{Binding StringValue}" HorizontalAlignment="Stretch" Padding="1" BorderThickness="0" Background="White" VerticalContentAlignment="Center"/>
			</DataTemplate>
		</Style.Resources>
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type my:StandardValueEditor}">
					<ContentPresenter Name="ValueHolder" ContentTemplate="{StaticResource UnselectedValueTemplate}" Content="{Binding RelativeSource={RelativeSource TemplatedParent}}">
						<ContentPresenter.ToolTip>
							<TextBlock Style="{x:Null}" Text="{TemplateBinding DescriptiveValue}"/>
						</ContentPresenter.ToolTip>
					</ContentPresenter>

					<ControlTemplate.Triggers>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="True"/>
								<Condition Property="IsEditable" Value="True"/>
							</MultiTrigger.Conditions>
							<Setter TargetName="ValueHolder" Property="ContentTemplate" Value="{StaticResource SelectedValueTemplate}"/>
						</MultiTrigger>
					</ControlTemplate.Triggers>

				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<Style TargetType="{x:Type my:BoolValueEditor}">
		<Style.Resources>
			<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		</Style.Resources>
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type my:BoolValueEditor}">
					<StackPanel Orientation="Horizontal">
						<CheckBox
							x:Name="PART_CheckBox"
							IsChecked="{Binding Value, Mode=TwoWay}"
							IsEnabled="{TemplateBinding IsEditable}"
							VerticalAlignment="Center"
						/>
						<TextBlock Margin="3,0" 
											 Text="{Binding Path=DescriptiveValue}"
											 Visibility="{Binding Path=IsExpression, Converter={StaticResource BooleanToVisibilityConverter}}"
											 VerticalAlignment="Center"
											 />
					</StackPanel>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<Style TargetType="{x:Type my:BrushValueEditor}">
		<Style.Resources>
			<DrawingBrush Stretch="Fill" TileMode="Tile" x:Key="CheckerboardBrush" Viewport="0,0,16,16" ViewportUnits="Absolute">
				<DrawingBrush.Drawing>
					<DrawingGroup>
						<GeometryDrawing Brush="White" Geometry="M 0,0 L 2,0 2,2 0,2 Z"/>
						<GeometryDrawing Brush="LightGray" Geometry="M 0,0 L 1,0 1,2 2,2 2,1 0,1 Z"/>
					</DrawingGroup>
				</DrawingBrush.Drawing>
			</DrawingBrush>

			<DataTemplate x:Key="UnselectedValueTemplate">
				<Grid Height="16" HorizontalAlignment="Left" ToolTip="{Binding DescriptiveValue}">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="48"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>
					<Rectangle Fill="{StaticResource CheckerboardBrush}"/>
					<Rectangle Fill="{Binding Value}" Stroke="{TemplateBinding TextElement.Foreground}" StrokeThickness="1"/>
					<TextBlock Grid.Column="1" Style="{x:Null}" Margin="5,0,0,0" Text="{Binding DescriptiveValue}"/>
				</Grid>
			</DataTemplate>

			<DataTemplate x:Key="SelectedValueTemplate">
				<my:EditTextBox Height="16" Text="{Binding StringValue}" HorizontalAlignment="Stretch" Padding="1" BorderThickness="0" Background="White" VerticalContentAlignment="Center"/>
			</DataTemplate>

			<DataTemplate x:Key="EmptyValueTemplate"/>
		</Style.Resources>
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type my:BrushValueEditor}">
					<ContentPresenter Name="ValueHolder" ContentTemplate="{StaticResource UnselectedValueTemplate}" Content="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>

					<ControlTemplate.Triggers>
						<DataTrigger Binding="{Binding Value}" Value="{x:Null}">
							<Setter TargetName="ValueHolder" Property="ContentTemplate" Value="{StaticResource EmptyValueTemplate}"/>
						</DataTrigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="True"/>
								<Condition Property="IsEditable" Value="True"/>
							</MultiTrigger.Conditions>
							<Setter TargetName="ValueHolder" Property="ContentTemplate" Value="{StaticResource SelectedValueTemplate}"/>
						</MultiTrigger>
					</ControlTemplate.Triggers>

				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<Style TargetType="{x:Type my:EnumValueEditor}">
		<Style.Resources>
			<DataTemplate x:Key="UnselectedValueTemplate">
				<TextBlock Style="{x:Null}" Text="{Binding DescriptiveValue}"/>
			</DataTemplate>

			<DataTemplate x:Key="SelectedValueTemplate">
				<ComboBox Height="16" Padding="2,-2,2,0" ItemsSource="{Binding Values}" IsSynchronizedWithCurrentItem="True"/>
			</DataTemplate>
		</Style.Resources>

		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type my:EnumValueEditor}">
					<ContentPresenter Name="ValueHolder" ContentTemplate="{StaticResource UnselectedValueTemplate}" Content="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>

					<ControlTemplate.Triggers>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsSelected" Value="True"/>
								<Condition Property="IsEditable" Value="True"/>
							</MultiTrigger.Conditions>
							<Setter TargetName="ValueHolder" Property="ContentTemplate" Value="{StaticResource SelectedValueTemplate}"/>
						</MultiTrigger>
					</ControlTemplate.Triggers>

				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
